package source.events.action;

import source.model.*;
import source.model.type.*;
import source.model.bonus.*;
import java.util.*;

public class LearnNewTechnologyAction implements Action{
	
	private int playerID;
	
	public LearnNewTechnologyAction(int playerID){
		this.playerID=playerID;
	}
	
	public ActionResult execute(DataHandler dh){
		Vector<Unit> v=dh.getPlayersUnits(playerID);
		Player p=dh.getPlayer(playerID);
		Bonus[] bonus=p.getUnitBonuses();
		for(Unit u:v){
			for(int i=0; i<bonus.length; i++)
				u.applyBonuses(bonus[i], dh);
		}
		dh.returnObjects(v.toArray(new Unit[0]));
		return ActionResult.SUCCESS;		
	}
}
